#ifndef __GLOBALDATA_H__
#define __GLOBALDATA_H__

#include "wx/wx.h"

#define ____GLOBAL_DATA_SIZE	(6000)
//#define ____DataTypeShort		(0)
//#define ____DataTypeUShort		(1)
//#define ____DataTypeInt32		(2)
//#define ____DataTypeUInt32		(3)
//#define ____DataTypeFloat		(4)



//300 On/Off
#define	T1_LSP				(301)
#define T1_MSP				(302)
#define T1_HSP				(303)
#define	T1_HDV				(304)
#define T1_LDV				(305)

#define	T2_LSP				(308)
#define T2_MSP				(309)
#define T2_HSP				(310)
#define	T2_HDV				(311)
#define T2_LDV				(312)

#define	T3_LSP				(315)
#define T3_MSP				(316)
#define T3_HSP				(317)
#define	T3_HDV				(318)
#define T3_LDV				(319)

#define	T4_LSP				(322)
#define T4_MSP				(323)
#define T4_HSP				(324)
#define	T4_HDV				(325)
#define T4_LDV				(326)

#define	T5_LSP				(329)
#define T5_MSP				(330)
#define T5_HSP				(331)
#define	T5_HDV				(332)
#define T5_LDV				(333)

#define	T6_LSP				(336)
#define T6_MSP				(337)
#define T6_HSP				(338)
#define	T6_HDV				(339)
#define T6_LDV				(340)

#define	T7_LSP				(343)
#define T7_MSP				(344)
#define T7_HSP				(345)
#define	T7_HDV				(346)
#define T7_LDV				(347)

#define	T8_LSP				(350)
#define T8_MSP				(351)
#define T8_HSP				(352)
#define	T8_HDV				(353)
#define T8_LDV				(354)

//400 IS	
#define	IS1_ITEM			(401)
#define IS1_TYPE			(402)
#define IS1_HIGH			(403)
#define IS1_LOW				(404)
#define IS1_DELAY_TM		(405)
#define IS1_BAND			(406)
#define	IS2_ITEM			(407)
#define IS2_TYPE			(408)
#define IS2_HIGH			(409)
#define IS2_LOW				(410)
#define IS2_DELAY_TM		(411)
#define IS2_BAND			(412)
#define	IS3_ITEM			(413)
#define IS3_TYPE			(414)
#define IS3_HIGH			(415)
#define IS3_LOW				(416)
#define IS3_DELAY_TM		(417)
#define IS3_BAND			(418)
#define	IS4_ITEM			(419)
#define IS4_TYPE			(420)
#define IS4_HIGH			(421)
#define IS4_LOW				(422)
#define IS4_DELAY_TM		(423)
#define IS4_BAND			(424)

#define	IS5_ITEM			(425)
#define IS5_TYPE			(426)
#define IS5_HIGH			(427)
#define IS5_LOW				(428)
#define IS5_DELAY_TM		(429)
#define IS5_BAND			(430)
#define	IS6_ITEM			(431)
#define IS6_TYPE			(432)
#define IS6_HIGH			(433)
#define IS6_LOW				(434)
#define IS6_DELAY_TM		(435)
#define IS6_BAND			(436)
#define	IS7_ITEM			(437)
#define IS7_TYPE			(438)
#define IS7_HIGH			(439)
#define IS7_LOW				(440)
#define IS7_DELAY_TM		(441)
#define IS7_BAND			(442)
#define	IS8_ITEM			(443)
#define IS8_TYPE			(444)
#define IS8_HIGH			(445)
#define IS8_LOW				(446)
#define IS8_DELAY_TM		(447)
#define IS8_BAND			(448)


//output 800

#define TEMP_OT				(800)
#define TEMP_DR				(801)
#define TEMP_CT				(802)
#define TEMP_ARW			(803)
#define TEMP_ATG			(804)

#define HUMI_OT				(808)
#define HUMI_DR				(809)
#define HUMI_CT				(810)
#define HUMI_ARW			(811)
#define HUMI_ATG			(812)

#define TEMP_RETT			(815)
#define TEMP_RETH			(816)
#define	TEMP_RETL			(817)
#define HUMI_RETT			(818)
#define HUMI_RETH			(819)
#define	HUMI_RETL			(820)


//INPUT 900
#define	TEMP_IN				(900)
#define	TEMP_RH				(901)
#define TEMP_RL				(902)
#define TEMP_BIAS			(903)
#define TEMP_INFL			(904)
#define TEMP_SH				(905)
#define TEMP_SL				(906)


#define HUMI_IN				(908)
#define HUMI_RH				(909)
#define HUMI_RL				(910)
#define HUMI_BIAS			(911)
#define HUMI_INFL			(912)
#define HUMI_DFL			(913)
#define HUMI_SH				(914)
#define HUMI_SL				(915)

#define DRY_LH				(920)
#define DRY_LL				(921)
#define WET_ADJ				(922)
#define DRY_TEMP			(923)
#define WET_TEMP			(924)
#define HUMI_PV				(925)

#define BP1_DDV				(933)
#define BP2_DDV				(934)
#define BP3_DDV				(935)
#define BP4_DDV				(936)
#define BP1_DPV				(937)
#define BP2_DPV				(938)
#define BP3_DPV				(939)
#define BP4_DPV				(940)

#define BP1_WDV				(943)
#define BP2_WDV				(944)
#define BP3_WDV				(945)
#define BP4_WDV				(946)
#define BP1_WPV				(947)
#define BP2_WPV				(948)
#define BP3_WPV				(949)
#define BP4_WPV				(950)






#define ____INTERPARM_PATH	wxT("\\Storage Card\\INTER.PARM")

class GlobalData
{
	GlobalData(void);

private:
	static unsigned short	m_data[____GLOBAL_DATA_SIZE];
	static unsigned short	m_olddata[____GLOBAL_DATA_SIZE];

	static bool DoGetData(int nIndex, void * lpVoid, int nCnt);
	static bool DoSetData( int nIndex, void * lpVoid, int nCnt );
public:
	template<typename T>
	static bool GetData(int nIndex, T& val) { return DoGetData(nIndex, &val, sizeof(T)); }
	template<typename T>
	static bool GetData(int nIndex, T* val, int size) { return DoGetData(nIndex, val, sizeof(T)*size); }

	template<typename T>
	static bool SetData(int nIndex, const T& val) { return DoSetData(nIndex, (void*)(const T*)&val, sizeof(T)); }
	template<typename T>
	static bool SetData(int nIndex, const T* val, int size) { return DoSetData(nIndex, (void*)val, sizeof(T)*size); }
	

	static void InitData();
	static void LoadInterSettings();
	static void SaveInterSettings();
	static bool GetInterSettingBytes(unsigned short data[]);
	static bool ParseInterSettingBytes(unsigned short data[]);
	static bool BackupSettings(LPCTSTR path);
	static bool RestoreSettings(LPCTSTR path);
	static void Test()
	{
		LoadInterSettings();
		SaveInterSettings();
		LoadInterSettings();
	}
};

#endif